package com.nuhu.controller;


import com.nuhu.pojo.CustomerServiceRecord;
import com.nuhu.pojo.Result;
import com.nuhu.pojo.User;
import com.nuhu.pojo.Worker;
import com.nuhu.service.admin_workerFucService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

@RestController
@Slf4j
public class admin_WorkerController {

    @Autowired
    private admin_workerFucService adminWorkerFucService;
    @GetMapping("/worker")
    public Result list(){
        log.info("查询全部员工记录");
        List<Worker> workerList = adminWorkerFucService.list();
        return Result.success(workerList);
    }

    @GetMapping("/AllWorkers")
    @ResponseBody
    public List<Worker> getWorkers(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size) {
        System.out.println("6666");
        return adminWorkerFucService.getWorkers(page, size);
    }


    @GetMapping("/searchWorkerPingFen")
    @ResponseBody
    public Worker searchUser(String WorkerID) {
        System.out.println("(controller)该值是"+WorkerID);
        System.out.println("jin ru Controller");
        return adminWorkerFucService.getWorkersPingFen(WorkerID);
    }



    @GetMapping("/searchWorkerFuWu")
    @ResponseBody
    public List<CustomerServiceRecord> searchWorkerFuWu(String WorkerID) {
        System.out.println("(controller)该值是"+WorkerID);
        System.out.println("jin ru Controller");
        return adminWorkerFucService.getWorkersFuWu(WorkerID);
    }

    @GetMapping("/deleteWorker")
    @ResponseBody
    public Worker deleteWorker(String WorkerID) {
        System.out.println("(controller)该值是"+WorkerID);
        System.out.println("jin ru Controller");
        return adminWorkerFucService.deleteWorker(WorkerID);
    }

    @GetMapping("/upSalary")
    @ResponseBody
    public void upSalary(BigDecimal Number,String WorkerID ) {
        System.out.println("(controller)该值是"+WorkerID);
        System.out.println("jin ru Controller");
        adminWorkerFucService.upSalary(Number,WorkerID);
    }

    @GetMapping("/downSalary")
    @ResponseBody
    public void downSalary(BigDecimal Number,String WorkerID) {
        System.out.println("(controller)该值是"+WorkerID);
        System.out.println("jin ru Controller");
        adminWorkerFucService.downSalary(Number,WorkerID);
    }
}
